//
//  BMRank.m
//  IntelligentSunglasses
//
//  Created by bosma on 14-4-24.
//  Copyright (c) 2014年 cn.com.bosma. All rights reserved.
//

#import "BMRank.h"
#import "CustomCell.h"
#import "CustomModal.h"
@interface BMRank ()
{
    NSMutableArray *_customArr;
}
@end

@implementation BMRank

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title = @"附近排行";
    }
    return self;
}

- (void)viewDidLoad
{
	[super viewDidLoad];
	
    
    
    //加载Plist
    NSArray * array = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"shops.plist" ofType:nil]];
    _customArr = [NSMutableArray array];
    //字典转模型
    for (NSDictionary *dict in array) {
        [_customArr addObject:[CustomModal customWithDict:dict]];
    }
    
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _customArr.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 100;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    CustomCell * cell = [tableView dequeueReusableCellWithIdentifier:[CustomCell customID]];
    if (!cell) {
        cell = [CustomCell customNib];
    }
    //取出数据模型
    CustomModal * custom= _customArr[indexPath.row];
    //传递数据模型
    cell.customModal = custom;
    
    return cell;
}



- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
